/*
 * Created on :Jul 26, 2012 Author :songlin.li
 */
package com.dmagic.cms.common.util.reflection;

import java.io.IOException;
import java.util.Date;

import com.dmagic.cms.common.util.DateUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

public class JSONDateSerializer extends JsonSerializer<Date> {

    @Override
    public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
            JsonProcessingException {
        String formattedDate = DateUtil.dateToString(value, DateUtil.FORMAT_6);
        jgen.writeString(formattedDate);
    }
}
